package geppetto.cat.models;

/**
 * a distortion table that puts distortions into bins based on the difference
 * between the current source word and the previous source word. Probability
 * mass that extends past the end ot the table is spread uniformly over the rest
 * of the length of the sentence.
 */
public abstract class AbstractDoubleDistortionTable {

	/** set all entries to 0. */
	public abstract void clear();

	/** set all entries to a uniform value */
	public abstract void uniform(double v);
	
//	/**
//	 * Copy the other distortion table to this one and also divide all the
//	 * values by their max
//	 */
//	public abstract void copyAndNormalize(AbstractDoubleDistortionTable counts);

	/**
	 * get the distortion probability given that we are notNull (i.e. don't use
	 * the nullDistProb here).
	 */
	public abstract double calcGivenNonnull(int si, int sprev, int len);

	/**
	 * get the probability that we align to position si given that we are in a
	 * sentence of length len and the previous word aligned to position sprev.
	 * FIXME -- this could be made much more efficient (at least we could save
	 * normalization).
	 */
	public abstract double getDistProb(int si, int sprev, int len);

	/**
	 * This method is useful since we are doing the normalization when builing
	 * the cache
	 * 
	 * @param si
	 * @param sprev
	 * @param len
	 * @return
	 */
	public abstract double getUnormalizedDistProb(int si, int sprev, int len);

	public abstract double getLastProb(int si, int len);

	public abstract double getFirstProb(int si, int len);

	/**
	 * get the probability of going from sprev to the null word at si in a
	 * sentence of length len -- currently uniform
	 */
	public abstract double getNullDistProb(int si, int sprev, int len);

	public abstract double tooBig(int sprev, int len);
	
	public abstract double tooSmall(int sprev, int len);

	// XXX check that this is correctly giving normalization when
	// we have nulls.
	public abstract double getNorm(int sprev, int len);

	public abstract void addToCount(double prob, int sprev, int si);

	public abstract void addToNullCount(double prob, int sprev, int si);

	public abstract void addToFirst(double prob, int si);

	public abstract void addToLast(double prob, int si, int len);
}
